import { createRouter, createWebHistory } from 'vue-router'
import { defineComponent, h } from 'vue'

// 空组件，用于子路由
const EmptyComponent = defineComponent({
  render() {
    return h('div')
  },
})

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('@/views/HomeView.vue'),
    },
    {
      path: '/practice',
      name: 'practice',
      component: () => import('@/views/PracticeView.vue'),
      redirect: '/practice/counter',
      children: [
        {
          path: 'counter',
          name: 'practice-counter',
          component: EmptyComponent,
        },
        {
          path: 'countdown',
          name: 'practice-countdown',
          component: EmptyComponent,
        },
        {
          path: 'bmi',
          name: 'practice-bmi',
          component: EmptyComponent,
        },
        {
          path: 'drink',
          name: 'practice-drink',
          component: EmptyComponent,
        },
        {
          path: 'todo',
          name: 'practice-todo',
          component: EmptyComponent,
        },
      ],
    },
  ],
})

export default router
